import React from 'react';
import ReactDOM from 'react-dom';
class App extends React.Component {
    constructor() {
        super();
        this.state = {
          name:"珠峰",
          psw:''
        }
    }
    change = (e)=>{
      this.setState({
        name:e.target.value
      })
      // this.state.name = e.target.value
    }
    componentDidMount(){
      // this.inp.value = this.state.name
    }
    changepsw = (e)=>{
      this.setState({
        psw:e.target.value
      })
    }
    changeName = (e)=>{
      this.setState({
        name:e.target.value
      })
    }
    submit = ()=>{
      console.log(this.state)
    }
    render() {
        let {name,psw} = this.state;
        // console.log(name)
        return <div className=''>

            {/* <input type="text" value={name} onChange={this.change}/>
            <input type="text" ref={(el)=>this.inp=el}/> */}
            <input type="text" placeholder='用户名' value={name} onChange={this.changeName}/>
            <input type="password" placeholder='密码' value={psw} onChange={this.changepsw}/>
            <button onClick={this.submit}>提交</button>
        </div>;
    }
}

ReactDOM.render(<App/>,document.getElementById('root'))